<?php

/*
 *	Application library
 */
namespace Application
{
	/*
	 *	Core class
	 *
	 *	@extends API
	 *	@final
	 */
	final class Core extends \Kernel
	{
		/*
		 *	Constructor
		 */
		public function __construct()
		{
			$this->libraries();
		}
		
		/*
		 *	Load libraries
		 */
		public function libraries()
		{
			/*
			 *	Debugger
			 */
			\Nano\Debug::getInstance();
			
			/*
			 *	Errors trapper
			 */
			\Autoload::getInstance('framework')->load('Trap');
			
			/*
			 *	Load configuration
			 */
			\Nano\Config::getInstance()->load('main');
			
			/*
			 *	Clear default headers
			 */
			\Nano\Headers::clear();
			
			/*
			 *	Caching
			 */
			\Nano\Cache::getInstance();
			
			/*
			 *	Otput controll
			 */
			\Nano\Output::getInstance();
			
			/*
			 *	Add some binds
			 */
			\Nano\Controller::getInstance()->bind
			(
				'^images/(.+)$',
				array
				(
					'callback' => array('Application\Controllers\Images', '__process'),
					'method' => 'get',
					'static' => false
				)
			);
			
			/*
			 *	And load controller
			 */
			 \Nano\Controller::getInstance()->int();
		}
		
		public function __destruct()
		{
			/*
			 *	Show output
			 */
			\Nano\Output::getInstance()->flush();
		}
	}
}